var t = getApp();

Page({
    data: {
        red: {},
        id: ""
    },
    onLoad: function(t) {
        this.getButton();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getButton: function() {
        var n = this, e = t.getNetAddresss("plugin.team-dividend.api.RedPack.index");
        e += "&id=" + this.options.id, t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 === e.result ? n.setData({
                    red: e.data.button
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getRed: function() {
        var n = this;
        if ("领取" === this.data.red.name) {
            var e = t.getNetAddresss("plugin.team-dividend.api.RedPack.receive");
            e += "&id=" + this.options.id, t._getNetWork({
                url: e,
                success: function(t) {
                    1 === t.data.result ? (n.getButton(), wx.navigateBack({
                        delta: 1
                    })) : wx.showToast({
                        title: t.data.msg,
                        icon: "none"
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});